package com.xmwzw.catpu.validator;

import java.util.regex.Pattern;

/**
 * Created by chenpeiqiang on 2017/11/28.
 */

public class PatternValidator extends Validator {
    private Pattern pattern;

    public PatternValidator(String _customErrorMessage, Pattern _pattern) {
        super(_customErrorMessage);
        if (_pattern == null) throw new IllegalArgumentException("_pattern must not be null");
        pattern = _pattern;
    }

    public boolean isValid(String value) {
        return pattern.matcher(value).matches();
    }

}
